﻿// <com.woyouqiu.Copyright>
// --------------------------------------------------------------
// <copyright>上海有求网络科技有限公司 2015</copyright>
// <Solution>Vecen.BangChuang</Solution>
// <Project>Vecen.BangChuang.Application</Project>
// <FileName>InsurancesAppService.cs</FileName>
// <CreateTime>2017-06-21 22:01</CreateTime>
// <Author>何苗</Author>
// <Email>hemiao@woyouqiu.com</Email>
// <log date="2017-06-21 22:01" version="00001">创建</log>
// --------------------------------------------------------------
// </com.woyouqiu.Copyright>

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Vecen.BangChuang.BangChuang.DomainServices.Agents;
using Vecen.BangChuang.Helpers;

namespace Vecen.BangChuang.BangChuang.Insurances {

    /// <summary>
    /// 
    /// </summary>
    public class InsurancesAppService: BangChuangAppServiceBase, IInsurancesAppService {
        private readonly AgentDomainService _agentDomainService;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="agentDomainService"></param>
        public InsurancesAppService(AgentDomainService agentDomainService) {
            _agentDomainService = agentDomainService;
        }

        /// <summary>
        /// 获得保险界面URL
        /// </summary>
        /// <returns></returns>
        public async Task<string> GetInsurancesUrl() {
            var orgUrl = await SettingManager.GetSettingValueAsync(BangChuangConsts.SettingsName.InsuranceH5Url);

            orgUrl += orgUrl.IndexOf("?", StringComparison.Ordinal) > 0 ? "&" : "?";

            return orgUrl + "agent=" + await _agentDomainService.GetCurrentAgentPrimaryKeyAsync();
        } 
    }
}